import axios from 'axios'
// import store from '@/store'
const request = axios.create({
        baseURL: window.PLATFROM_CONFIG.baseUrl,    //配置文件[/public/config.js],
        timeout: 5000
    }
)
//配置拦截器，设置请求数据
request.interceptors.request.use(
  // config => {
  //   // do something before request is sent
  //   //判断是否能获取token
  //   if (store.getters.token) {
  //     // let each request carry token
  //     // ['X-Token'] is a custom headers key
  //     // please modify it according to the actual situation
  //     config.headers['X-Token'] = getToken()  //设置token
  //   }
  //   return config
  // },
  // error => {
  //   // do something with request error
  //   console.log(error) // for debug
  //   return Promise.reject(error)
  // }
)

//配置拦截器，封装response数据
request.interceptors.response.use(
  response => {
    const res = response.data
    return res;
  }
)
let http = {
  get : function(url, params) {
    return request({
        url:url,
        method:'get',
        params:params
  
    })
  },
  post : function(url, params) {
    return request({
        url:url,
        method:'post',
        params:params
  
    })
  }
}
export default http